<!DOCTYPE html>
<html lang="en">
	<head>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta charset="UTF-8">
		<title>充值</title>
		<link rel="stylesheet" type="text/css" href="__STATIC__/home/css/reset.css">
		<script src="__STATIC__/home/js/base.js"></script>
		<link rel="stylesheet" href="__STATIC__/home/css/mycz.css">
	</head>
<body>
	<div class="container">
		<a href="javascript:;" class="active">充值</a>
		<a href="mytx.html" class="">提现</a>
	</div>
	<!-- 充值 -->
	<div class="cz">
		<div class="lx">
			<span>充值类型</span>
			<select name="" id="lx">
				<option value="1">支付宝</option>
				<option value="2">微信</option>
				<option value="3">银行卡</option>
			</select>
		</div>
		<div class="change">
			<div class="e1">
				<img class="ewm" src="__STATIC__/home/images/ewm.jpg" alt="">
				<p>长按或者扫描二维码充值</p>
			</div>
			<!-- 银行卡 -->
			<div class="ka">
				<form action="" method="post" id="formdata">
					<ul>
						<li>
							<span>用户名</span>
							<p>{$user['name']}</p>
						</li>
						<li>
							<span>账号余额</span>
							<p>{$user['money']}</p>
						</li>
						<li>
							<span>充值金额</span>
							<input type="number" name="money" id="money">
						</li>
						<li>
							<span>充值类型</span>
							<select name="type" id="lx2">
								<option value="1">支付宝</option>
								<option value="2">微信</option>
								<option value="3" selected>银行卡</option>
							</select>
						</li>
						<li>
							<span>充值账号</span>
							<input type="number" name="number" id="zhanghao">
						</li>
						<li>
							<span>开户行</span>
							<input type="text" name="adds" >
						</li>
						<li>
							<span>收款人</span>
							<input type="text" name="putuser">
						</li>
					</ul>
					<button class="btn">确认充值</button>
				</form>
			</div>
		</div>
	</div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
	function changeC(ele) {
		$(ele).change(function() {
			let str = $(ele).find('option:selected').val()
			console.log(str)
			if(str == 3) {
				$('.lx').hide();
				$('.e1').hide();
				$('#lx2').html(`<option value="1">支付宝</option>
							<option value="2">微信</option>
							<option value="3" selected>银行卡</option>`)
				$('.ka').show();
			}else if( str == 1 ) {
				$('#lx').html(`<option value="1" selected>支付宝</option>
							<option value="2">微信</option>
							<option value="3">银行卡</option>`)
				$('.ka').hide();
				$('.lx').show();
				$('.e1').show();
			}else if( str == 2 ) {
				$('#lx').html(`<option value="1">支付宝</option>
							<option value="2" selected>微信</option>
							<option value="3">银行卡</option>`)
				$('.ka').hide()
				$('.lx').show();
				$('.e1').show();
			}
		})
	}
	changeC('#lx');
	changeC('#lx2');
	
	
	// 提交
	$(".btn").click(function(){
		var bool=true;
		var moneyInput;
		$('input').each(function(i){
			if(i==1){
				moneyInput = $(this);
			}
			if(!$(this).val()) bool=false;
		})
		if(bool){
			if(moneyInput.val() <= 0){
				alert("请填写正确的金额!");
				moneyInput.val("");
			}else{
				$("#formdata").submit();
			}
		}else{
			alert("请将数据填写完整！");
		}
	})
</script>
</html>